﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Example {
  public partial class WebForm2_5 : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {

    }
    protected void btnView_Click(object sender, EventArgs e) {
      lblView.Text = "你的兴趣有：";
      for (int i = 0; i < chkHobby.Items.Count; i++)
        if (chkHobby.Items[i].Selected == true)
          lblView.Text += chkHobby.Items[i].Value + " ";
      //第二种遍历方法
      /*foreach (ListItem item in chkHobby.Items)
          if (item.Selected)
            lblView.Text += " " + item.Value;
       */
    }
  }
}